package com.ngc.mall.controller;

import com.ngc.mall.common.configure.response.ResponseResult;
import com.ngc.mall.service.IOrderService;
import com.ngc.mall.service.ISpuService;
import com.ngc.mall.service.IWxUserService;
import com.ngc.mall.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  统计
 *
 * @author : Chen Xiao Lin
 * @Date : 2023/5/15 10:47
 **/
@RestController
@RequestMapping("/report")
@Api(tags = "统计")
public class ReportController {
    @Autowired
    private IOrderService iOrderService;

    @Autowired
    private ISpuService iSpuService;

    @Autowired
    private IWxUserService iWxUserService;

    @GetMapping("/overview/spu")
    @ApiOperation(value="获取商品总览")
    public ResponseResult<SpuOverviewVO> getSpuOverView(){
        return ResponseResult.success(iSpuService.getSpuOverview());
    }


    @GetMapping("/overview/order")
    @ApiOperation(value="获取订单数量总览")
    public ResponseResult<OrderOverviewVO> getOrderOverView(){
        return ResponseResult.success(iOrderService.getOrderOverview());
    }


    @GetMapping("/overview/member")
    @ApiOperation("获取会员总览")
    public ResponseResult<MemberOverviewVO> getMemberOverView(){
        return ResponseResult.success(iWxUserService.getMemberOverview());
    }


    @GetMapping("/order/current/{type}")
    @ApiOperation("获取当前不同日期类型的订单交易情况")
    public ResponseResult<OrderReportSummaryVO> queryCurrentOrderByDateType(@PathVariable int type){
        return ResponseResult.success(iOrderService.queryOrderByDateType(type));
    }
}
